package io.renren.modules.busi.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.busi.entity.GeneratordemoEntity;
import io.renren.modules.busi.service.GeneratordemoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 生成器测试表
 *
 * @author zj
 * @email 465189260@qq.com
 * @date 2020-08-20 07:04:51
 */
@RestController
@RequestMapping("busi/generatordemo")
public class GeneratordemoController {
    @Autowired
    private GeneratordemoService generatordemoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("busi:generatordemo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = generatordemoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{zbsjId}")
    @RequiresPermissions("busi:generatordemo:info")
    public R info(@PathVariable("zbsjId") Long zbsjId){
        GeneratordemoEntity generatordemo = generatordemoService.getById(zbsjId);

        return R.ok().put("generatordemo", generatordemo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("busi:generatordemo:save")
    public R save(@RequestBody GeneratordemoEntity generatordemo){
        generatordemoService.save(generatordemo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("busi:generatordemo:update")
    public R update(@RequestBody GeneratordemoEntity generatordemo){
        ValidatorUtils.validateEntity(generatordemo);
        generatordemoService.updateById(generatordemo);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("busi:generatordemo:delete")
    public R delete(@RequestBody Long[] zbsjIds){
        generatordemoService.removeByIds(Arrays.asList(zbsjIds));

        return R.ok();
    }

}
